const axios = require("axios");

const apiUrl = "https://iot-api.heclouds.com/thingmodel/query-device-property";
const apiUrl1 =
  "https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=60dc4e97-0f75-4fc3-8aba-420a0e8b4112";
const apiUrl2 = "https://iot-api.heclouds.com/thingmodel/set-device-property";
const deviceName = "d1";
const productid = "zy1NTZomN9";
const authorizationKey =
  "version=2022-05-01&res=userid%2F378829&et=1745595703&method=sha1&sign=MbkKStlGzWOmL1%2BbgO3bkDcCYYQ%3D"; // 请将 'your_authorization_key' 替换为实际的授权 key

const headers = {
  authorization: authorizationKey,
};


function sendDataToApi() {
  const posttime = "1714923152102"; // 示例 posttime 值，你可以根据实际情况设置
  console.log(posttime)
  const data = {
    device_name: "d1",
    product_id: "zy1NTZomN9",
    params: {
      server: 1714923152102
      
    }
  };

  const config = {
    headers: headers
  };

  axios.post(apiUrl2, data, config)
    .then((response) => {
      console.log(response.data);
      console.log("数据发送成功");
    })
    .catch((error) => {
      console.error("发送数据失败:", error);
    });
}

sendDataToApi();
